﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Reflection;

namespace DrinkcounterUi
{
    public class Person
    {
        private static int internalId = 0;

        public Person(string id)
        {
            Locked = new Timer();
            this.Id = id;
            Locked.Interval = 2000;
            Locked.Tick += new EventHandler(Locked_Tick);

            List<Color> colors = new List<Color>();
            foreach (PropertyInfo pi in typeof(Color).GetProperties())
            {
                if (pi.Name.StartsWith("Light"))
                    colors.Add((Color)pi.GetValue(pi, null));
            }

            if (Properties.Settings.Default.UseColors) Color = colors[internalId++ % colors.Count];
            else Color = Button.BackColor;
        }

        void Locked_Tick(object sender, EventArgs e)
        {
            Locked.Stop();
            Button.Enabled = true;
            Button.BackColor = Color;
        }

        public Button Button { get; set; }

        public string Name { get; set; }

        public string Id { get; set; }

        public double Alcohol { get; set; }

        public int Drinks { get; set; }

        public Timer Locked { get; set; }

        public Color Color { get; set; }

        public string Idletime { get; set; }
    }
}
